<style lang="less">
  @import "./score-editor.less";
</style>

<template>
  <div class="score-editor">
    <span class="score-editor-value">{{ value }}分</span>

    <span class="score-editor-sign">*</span>

    <a-input v-model="scale" size="small" />

    <a-divider />

    <a-button
      ghost
      size="small"
      type="primary"
      @click="handleConfirm"
    >
      确定
    </a-button>
  </div>
</template>

<script>
export default {
  props: {
    value: {
      type: Number,
      default: 0,
    },

    weight: {
      type: Number,
      default: 0,
    },
  },

  data () {
    return {
      scale: this.weight,
    }
  },

  methods: {
    handleConfirm (ev) {
      const weight = parseInt(this.scale, 0) || 0

      this.$emit('confirm', weight, ev)
    },
  },
}
</script>
